'''
Student.count 为类属性，所有实例共有
'''
class Student(object):
    count = 0
    def __init__(self, name):
        self.name = name
        #类属性自增
        Student.count+=1
    def getCount(self):
        #返回共创建的实例个数
        return Student.count

#测试代码
Stu1=Student("aaa")
print(Stu1.name,Stu1.getCount())
Stu2=Student("bbb")
print(Stu2.name,Stu2.getCount())
